package com.system.appointment.service;

import com.system.appointment.bean.Appointment;
import com.system.appointment.dto.AppointmentDTO;
import com.system.appointment.dto.CallingMachineDTO;
import com.system.appointment.dto.PatientQueryDTO;
import com.system.appointment.vo.AppointmentListVO;
import com.system.appointment.vo.AppointmentPatientDetailVO;
import com.system.appointment.vo.CallingMachineVo;

import java.util.List;

/**
 * @className: AppointmentService
 * @description:预约单Service接口（抽象类）
 * @author: Li Chuanwei
 * @date: 2023/11/12 15:35
 * @Company: Copyright [日期] by [作者或个人]
 **/

public abstract class AppointmentService {
    public abstract boolean saveAppointment(Appointment appointment);
    public abstract boolean removeAppointmentById(int id);
    public abstract boolean modifyAppointment(Appointment appointment);
    public abstract Appointment getAppointmentById(int id);
    public abstract List<Appointment> listAllAppointments();
    public abstract boolean cancelAppointment(int id);
    public final Integer processAppointment(AppointmentDTO appointmentDTO) {
        if(checkEligibility()){
            Integer state = bookAppointment(appointmentDTO);
            if(state != -1){
                notifyUser();
                return state;
            }
        }
        return -1;
    }

    // 钩子方法：检查预约资格
    protected abstract boolean checkEligibility();

    // 抽象方法：预约挂号
    protected abstract Integer bookAppointment(AppointmentDTO appointmentDTO);

    // 钩子方法：通知用户
    protected void notifyUser() {
        System.out.println("Notification sent to the user.");
    }

    public abstract AppointmentPatientDetailVO getPatientDetail(int id);

    public abstract boolean cancelUnpaidAppointment();

    public abstract Integer paySuccess(String outTradeNo);

    public abstract List<AppointmentListVO> getAppointmentList(PatientQueryDTO patientQueryDTO);

    public abstract CallingMachineVo getAppointmentByPatientIdCardNumber(CallingMachineDTO callingMachineDTO) ;
}
